package com.itheima.stream流.实例;

import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;

public class Demo4 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<String>();
        Collections.addAll(list,"林青霞","张曼玉","王祖贤","柳岩","张敏","张无忌","张三丰","张翠山");
        //1
        Stream<String> limit = list.stream().limit(6);
        //limit.forEach(System.out::println);
        System.out.println("======================");
        //2
        Stream<String> skip = list.stream().skip(list.size()-3);
        //skip.forEach(s-> System.out.println(s));
        System.out.println("======================");
        //3
        Stream<String> concat = Stream.concat(limit, skip);
        //concat.forEach(System.out::println);
        System.out.println("======================");
        //4
        Stream<String> distinct = concat.distinct();
        distinct.forEach(System.out::println);


    }
}
